import React from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { List, Icon,TextareaItem,ActivityIndicator } from 'antd-mobile';
import content from '../../../common/contentCss/content.css';
import CustTitle from '../../../common/title/title';
import Authentication from './pages/certification/Authentication';

function CheckRealName({dispatch,loading,checkRealName,personal}) {
  const {profile} = checkRealName;
  const { personalData } = personal;

  // console.log('personalData', JSON.stringify(personalData));

  const titleProps = {
    titleName:'实名认证',
    goBack(){
      history.go(-1);
    }
  }

  let isValidate = false;
  if(personalData){
    if(personalData.verification == 'PASS' || personalData.verification == 'AUTHENTICATING'){
      isValidate = true
    }
  }

  const AuthenticationProps = {
    profile,
    personalData,
    isValidate,
    onUploadImg(data) {
      console.log('上传图片上传图片',data);
      dispatch({
        type:'checkRealName/onUploadImg',
        payload:{
          data
        }
      })
    },
    onSubmit(data) {
      console.log('上传成功');
      console.log(data);
      dispatch({
        type:'checkRealName/onSubmit',
        payload:{
          data
        }
      })
    },
  };


  const MarginHeight = () => <div style={{height: '0.6em', backgroundColor:'#F5F5F9'}}></div>;

  return(
    <div className={content.content} style={{backgroundColor:'#fff'}}>
      <CustTitle {...titleProps}/>
      <div style={{
          marginTop: '2.8125em',
      }}>
      </div>
      <Authentication {...AuthenticationProps} />
      <ActivityIndicator
        toast
        text=""
        animating={loading}
      />
    </div>
  )
}

function mapStateToProps(state, ownProps) {
  return {
    loading: state.loading.global,
    checkRealName: state.checkRealName,
    personal:state.personal
  }
}

export default connect(mapStateToProps)(CheckRealName);
